package config

import (
	"io/ioutil"

	"gopkg.in/yaml.v2"
)

type ServerConfig struct {
	Url        string `yaml:"url"`
	SecretId   string `yaml:"secretId"`
	SecretKey  string `yaml:"secretKey"`
	ListenAddr string `yaml:"listenAddr"`
}

func ReadConfig(fileName string) (*ServerConfig, error) {
	data, err := ioutil.ReadFile(fileName)
	if err != nil {
		return nil, err
	}
	servCfg := &ServerConfig{}
	err = yaml.Unmarshal(data, servCfg)
	if err != nil {
		return nil, err
	}
	return servCfg, nil
}
